<?php
class media {
	private $id;
	private $name;
	private $description;
	private $category;
	#	private $description;
	#	private $description;
	#	private $description;
	#	private $description;
	#	private $description;
	#	private $description;
	

	public function setid($id) {
		$this->id = $id;
	}
	public function getid() {
		return $this->id;
	}
	// set get name
	public function setname($name) {
		$this->name = $name;
	}
	public function getname() {
		return $this->name;
	}
	// set get category
	public function setcategory($category) {
		$this->category = $category;
	}
	public function getcategory() {
		return $this->category;
	}
	// set get description
	public function setdescription($description) {
		$this->description = $description;
	}
	public function getdescription() {
		return $this->description;
	}
	
	public function getone() {
		GLOBAL $db;
		$sql = "SELECT * FROM " . $db->tbl_fix . "media where m_id='" . $this->id . "'";
		$return = $db->executeQuery ( $sql, 2 );
		return $return;
	}
	// check login
	public function listall() {
		GLOBAL $db;
		$sql = "SELECT * FROM " . $db->tbl_fix . "media";
		$result = $db->executeQuery ( $sql );
		while ( $rows = mysql_fetch_array ( $result ) ) {
			$return [] = $rows;
		}
		return $return;
	}
	public function top10() {
		GLOBAL $db;
		$sql = "SELECT * FROM " . $db->tbl_fix . "media as a , " . $db->tbl_fix . "media_cat as b where a.mcat_id = b.mcat_id order by a.m_date DESC limit 0,10 ";
		$result = $db->executeQuery ( $sql );
		while ( $rows = mysql_fetch_array ( $result ) ) {
			$return [] = $rows;
		}
		return $return;
	}
	public function listbycat() {
		GLOBAL $db;
		$sql = "SELECT * FROM " . $db->tbl_fix . "media where mcat_id='" . $this->category . "'";
		$result = $db->executeQuery ( $sql );
		while ( $rows = mysql_fetch_array ( $result ) ) {
			$return [] = $rows;
		}
		return $return;
	}
	public function delete() {
		GLOBAL $db;
		$sql = "DELETE FROM " . $db->tbl_fix . "product where `id` ='" . $this->id . "'";
		$db->executeQuery ( $sql );
	}

}
$media = new media ();
?>